﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

using Com.Framework.Extension;
using Com.Library.DB.Banner;
using Com.Library.DB.Popup;
using Com.Library.DB.Store;
using Com.Library.DB.Contribute;

using Com.Web.coffinegurunaru.AppLogic.Page;

namespace Com.Web.coffinegurunaru.home
{
    public partial class _default : WebPage
    {
        public List<BannerEntity> CenterBanner
        {
            get;
            set;
        }

        public BannerEntity BrandBanner
        {
            get;
            set;
        }

        public BannerEntity MenuBanner
        {
            get;
            set;
        }

        public BannerEntity MediaBanner
        {
            get;
            set;
        }

        public BannerEntity EventBanner
        {
            get;
            set;
        }

		public List<PopupEntity> PopupList
		{
			get;
			set;
		}

		public List<StoreMainEntity> StoreList
		{
			get;
			set;
		}

		public List<ContributeEntity> ContributeList
		{
			get;
			set;
		}

        protected void Page_Load(object sender, EventArgs e)
        {
            CenterBanner = BannerModel.GetList(1, 1, 20);

			BrandBanner = GetBannerInfo(2);
			MenuBanner = GetBannerInfo(3);
			MediaBanner = GetBannerInfo(4);
			EventBanner = GetBannerInfo(5);
			
			try
			{
				PopupList = PopupModel.GetList(1, 5).Record;
			}
			catch
			{
				PopupList = new List<PopupEntity>();
			}

			try
			{
				StoreList = StoreModel.MainGetList(4);
			}
			catch
			{
				StoreList = new List<StoreMainEntity>();
			}

			try
			{
				ContributeList = ContributeModel.GetList(1, 5).Record;
			}
			catch
			{
				ContributeList = new List<ContributeEntity>();
			}
        }

		private BannerEntity GetBannerInfo(int BannerID)
		{
			try
			{
				List<BannerEntity> BannerList = BannerModel.GetList(BannerID, 1, 20).GetRandom(1);
				if (BannerList.Count == 0)
					return new BannerEntity();
				return BannerList[0];
			}
			catch
			{
				return new BannerEntity();
			}
		}
    }
}
